This patch is needed for kexec/kdump since VCPU#0 is halted.
Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
#define vcpu_vhpet(vcpu) (domain_vhpet((vcpu)->domain))
#define vhpet_domain(hpet) (container_of((hpet), struct domain, \
arch.hvm_domain.pl_time.vhpet))
-#define vhpet_vcpu(hpet) (vhpet_domain(hpet)->vcpu[0])
+#define vhpet_vcpu(hpet) (pt_global_vcpu_target(vhpet_domain(hpet)))
#define HPET_BASE_ADDRESS 0xfed00000ULL
#define HPET_MMAP_SIZE 1024
#define vcpu_vpit(vcpu) (domain_vpit((vcpu)->domain))
#define vpit_domain(pit) (container_of((pit), struct domain, \
arch.hvm_domain.pl_time.vpit))
-#define vpit_vcpu(pit) (vpit_domain(pit)->vcpu[0])
+#define vpit_vcpu(pit) (pt_global_vcpu_target(vpit_domain(pit)))
#define RW_STATE_LSB 1
#define RW_STATE_MSB 2
#define vcpu_vrtc(vcpu) (domain_vrtc((vcpu)->domain))
#define vrtc_domain(rtc) (container_of((rtc), struct domain, \
arch.hvm_domain.pl_time.vrtc))
-#define vrtc_vcpu(rtc) (vrtc_domain(rtc)->vcpu[0])
+#define vrtc_vcpu(rtc) (pt_global_vcpu_target(vrtc_domain(rtc)))
static void rtc_periodic_cb(struct vcpu *v, void *opaque)
{
v = d->vcpu ? d->vcpu[0] : NULL;
found:
+ if ( d->arch.hvm_domain.i8259_target == v )
+ return;
d->arch.hvm_domain.i8259_target = v;
+ pt_adjust_global_vcpu_target(v);
}
int vlapic_has_pending_irq(struct vcpu *v)
*/
kill_timer(&pt->timer);
}
+
+static void pt_adjust_vcpu(struct periodic_time *pt, struct vcpu *v)
+{
+ int on_list;
+
+ ASSERT(pt->source == PTSRC_isa);
+
+ if ( pt->vcpu == NULL )
+ return;
+
+ pt_lock(pt);
+ on_list = pt->on_list;
+ if ( pt->on_list )
+ list_del(&pt->list);
+ pt->on_list = 0;
+ pt_unlock(pt);
+
+ spin_lock(&v->arch.hvm_vcpu.tm_lock);
+ pt->vcpu = v;
+ if ( on_list )
+ {
+ pt->on_list = 1;
+ list_add(&pt->list, &v->arch.hvm_vcpu.tm_list);
+
+ migrate_timer(&pt->timer, v->processor);
+ }
+ spin_unlock(&v->arch.hvm_vcpu.tm_lock);
+}
+
+void pt_adjust_global_vcpu_target(struct vcpu *v)
+{
+ struct pl_time *pl_time = &v->domain->arch.hvm_domain.pl_time;
+ int i;
+
+ if ( v == NULL )
+ return;
+
+ spin_lock(&pl_time->vpit.lock);
+ pt_adjust_vcpu(&pl_time->vpit.pt0, v);
+ spin_unlock(&pl_time->vpit.lock);
+
+ spin_lock(&pl_time->vrtc.lock);
+ pt_adjust_vcpu(&pl_time->vrtc.pt, v);
+ spin_unlock(&pl_time->vrtc.lock);
+
+ spin_lock(&pl_time->vhpet.lock);
+ for ( i = 0; i < HPET_TIMER_NUM; i++ )
+ pt_adjust_vcpu(&pl_time->vhpet.pt[i], v);
+ spin_unlock(&pl_time->vhpet.lock);
+}
void pt_reset(struct vcpu *v);
void pt_migrate(struct vcpu *v);
+void pt_adjust_global_vcpu_target(struct vcpu *v);
+#define pt_global_vcpu_target(d) \
+ ((d)->arch.hvm_domain.i8259_target ? : (d)->vcpu ? (d)->vcpu[0] : NULL)
+
/* Is given periodic timer active? */
#define pt_active(pt) ((pt)->on_list)